package day08;

public class StringCompareDemo {
    public static void main(String[] args) {
        String s1 = new String("abc");
        String s2 = new String("abc");
        System.out.println(s1==s2);

        String s3 = "abc";
        String s4 = "abc";
        System.out.println(s3 == s4);

        System.out.println(s1 == s3);

        String s5 = "a" + "b" + "c";
        System.out.println(s1 == s3);
        String s6 = "a";
        String s7 = s6 + "b";
        System.out.println("ab" == s7);

        final String s66 = "a";
        String s77 = s66 + "b";
        System.out.println("ab" == s77);

        String s8 = "ab";
        System.out.println(s8 == get());

        System.out.println(s8 == getStr());

        System.out.println("abc" == s1.intern());

        System.out.println(s1.equals(s1));

    }

    public static String get(){
        return "ab";
    }

    public static String getStr(){
        return new String("ab");
    }
}
